<script>
export default {
    name: "itemInput",
    props: {
        value: [Number, String, undefined, null],
        config: Object,
        change: Function,
    },
    data() {
        return {
            configSelf: {},
            options: null,
            valueSelf: undefined,
        };
    },
    watch: {
        config: {
            handler(val) {
                if (val) {
                    this.init();
                }
            },
            deep: true,
            immediate: true,
        },
        value: {
            handler(val) {
                this.valueSelf = val;
            },
            immediate: true,
        }
    },
    methods: {
        init() {
            this.configSelf = { ...this.config };
            // 处理placeholder
            this.configSelf.placeholder = this.config?.placeholder || `请输入${this.config?.label}`;
        },
        setValueSelf(value) {
            this.change(value);
        },
    },
    render() {
        return (
            <el-input
                vModel={this.valueSelf}
                onChange={this.setValueSelf}
                props={{ ...this.configSelf }}
                placeholder={ this.configSelf?.placeholder}
            />
        );
    },
};
</script>
